package UDP;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDicServer extends UdpEchoServer{
    private HashMap<String,String> dic = new HashMap<>();
    public UdpDicServer(int port) throws SocketException {
        super(port);
        //构造出一部字典来
        dic.put("hello","你好");
        dic.put("world","世界");
        dic.put("client","客户");
        dic.put("server","服务");
        dic.put("red","红色");
        dic.put("read","读");
    }
    @Override
    public String process(String request){
        return dic.getOrDefault(request, "没有找到该单词");
    }

    public static void main(String[] args) throws IOException {
        UdpDicServer server = new UdpDicServer(6060);
        server.start();
    }
}
